# -*- coding: utf-8 -*-
from common import orm
from common.utils.types import Enum

PAY_STATUS = Enum({
    "READY": (0L, u"未支付"),
    "FAIL": (1L, u"支付失败"),
    "SUCC": (2L, u"支付成功"),
    "OVERTIME": (3L, u"超时"),
    "MANUAL_SUCC": (4L, u"人工补单"),
})

NOTIFY_STATUS = Enum({
    "READY": (0L, "ready to notify"),
    "FAIL": (1L, "notify failed"),
    "SUCC": (2L, "notify successed"),
})


class Order(orm.Model):
    """
    上分 订单信息
    """
    __tablename__ = "order"
    id = orm.Column(orm.Integer, primary_key=True, autoincrement=True)
    mch_id = orm.Column(orm.Integer)
    bankcard_name = orm.Column(orm.VARCHAR)
    bankcard_num = orm.Column(orm.VARCHAR)
    user_id = orm.Column(orm.Integer)
    out_trade_no = orm.Column(orm.VARCHAR)
    body = orm.Column(orm.VARCHAR)
    total_fee = orm.Column(orm.FLOAT)
    real_amount = orm.Column(orm.FLOAT)
    record_id = orm.Column(orm.Integer)
    sms_id = orm.Column(orm.Integer)
    status = orm.Column(orm.Integer, default=0)
    notify_url = orm.Column(orm.VARCHAR)
    mch_create_ip = orm.Column(orm.VARCHAR)
    sign = orm.Column(orm.VARCHAR)
    extra = orm.Column(orm.VARCHAR)
    extend = orm.Column(orm.VARCHAR)
    notify_status = orm.Column(orm.Integer, default=0)
    notify_count = orm.Column(orm.Integer, default=0)
    notify_failed_retry = orm.Column(orm.Integer, default=0)
    payed_at = orm.Column(orm.DATETIME)
    notified_at = orm.Column(orm.DATETIME)
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    operator = orm.Column(orm.VARCHAR)
    notes = orm.Column(orm.VARCHAR)
    pay_type = orm.Column(orm.VARCHAR)
